package com.kingdee.eas.custom.hr.attendance.app;

import java.util.HashSet;
import java.util.Iterator;

import org.apache.log4j.Logger;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.custom.hr.attendance.AttendanceTimeConfigInfo;
import com.kingdee.eas.hr.compensation.CmpPeriodCollection;
import com.kingdee.eas.hr.compensation.CmpPeriodFactory;
import com.kingdee.eas.hr.compensation.CmpPeriodInfo;

public class AttendanceTimeConfigControllerBean extends
		AbstractAttendanceTimeConfigControllerBean {
	private static Logger logger = Logger
			.getLogger("com.kingdee.eas.custom.hr.attendance.app.AttendanceTimeConfigControllerBean");

	@Override
	protected IObjectPK _addnew(Context ctx, IObjectValue model)
			throws BOSException, EASBizException {

		AttendanceTimeConfigInfo info = (AttendanceTimeConfigInfo) model;
		HashSet addNewSet = new HashSet();
		addNewSet = (HashSet) info.get("newCmpPeriodInfo");
		Iterator addNewIterator = addNewSet.iterator();
		IObjectPK pkLastAddNew = null;
		while (addNewIterator.hasNext()) {
			AttendanceTimeConfigInfo infoTemp = (AttendanceTimeConfigInfo) addNewIterator
					.next();
//			infoTemp
//					.setPeriod(this.getCmpPeriodInfo(ctx, infoTemp.getNumber()));
			pkLastAddNew = super._addnew(ctx, infoTemp);
		}

		return pkLastAddNew;
	}



	protected void _update(Context ctx, IObjectPK pk, IObjectValue model)
			throws BOSException, EASBizException {
		AttendanceTimeConfigInfo info = (AttendanceTimeConfigInfo) model;
		HashSet updateSet = new HashSet();

		updateSet = (HashSet) info.get("modifyCmpPeriodInfo");
		Iterator updateIterator = updateSet.iterator();
		IObjectPK pkUpdate = null;
		while (updateIterator.hasNext()) {
			AttendanceTimeConfigInfo infoTemp = (AttendanceTimeConfigInfo) updateIterator
					.next();
			pkUpdate = new ObjectUuidPK(infoTemp.getId());
			super._update(ctx, pkUpdate, infoTemp);
		}
	}

}